using System;
using System.Diagnostics;
using System.Windows.Forms;
namespace Gl.SettingsManager
{
	[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
	public class WindowStateValidatorAttribute : SettingValidatorBaseAttribute
	{
		private bool _allowMinimized = false;

		public bool AllowMinimized
		{
			get { return _allowMinimized; }
			set { _allowMinimized = value; }
		}

		public override void Validate(ref object value)
		{
			Debug.Assert(value is FormWindowState);

			FormWindowState state = (FormWindowState)value;
			if (state == FormWindowState.Minimized && !_allowMinimized)
				state = FormWindowState.Normal;

			value = state;
		}
	}
}
